package com.fenghongzhang.day005;


import android.content.Context;
import android.os.Bundle;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.Fragment;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;

import com.fenghongzhang.day005.R;

import java.util.List;


public class BlankFragment extends Fragment {

    public BlankFragment() {
        // Required empty public constructor
    }
    private EditText fEdit;
    private Button fSend;
    //赋值
    private MyListener myListener;
    //接口
    public interface MyListener{
        void message(String s);
    }

    @Override
    public void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

    }

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        // Inflate the layout for this fragment
        View inflate = inflater.inflate(R.layout.fragment_blank, container, false);


        //赋值
        myListener = (MyListener) getActivity().getSupportFragmentManager().findFragmentByTag("hehe");

        fEdit = (EditText) inflate.findViewById(R.id.f_edit);
        fSend = (Button) inflate.findViewById(R.id.f_send);
        fSend.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                String s = fEdit.getText().toString();
                myListener.message(s);
            }
        });
        return inflate;
    }

}
